<link rel="stylesheet" type="text/css" href="__STATIC__/admin_page/static/h-ui/css/H-ui.min.css"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin_page/static/h-ui.admin/css/H-ui.admin.css"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin_page/lib/Hui-iconfont/1.0.8/iconfont.css"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin_page/static/h-ui.admin/skin/default/skin.css" id="skin"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin_page/static/h-ui.admin/css/style.css"/>
<script type="text/javascript" src="/static/js/vue2.5.1.js"></script>
<script src="/static/js/axios.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin_page/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin_page/lib/layer/2.4/layer.js"></script>
<script src="/static/js/jquery.base64.js"></script>
<div class="page-container" id="password">
    <article class="cl pd-20">
        <form action="" method="post" class="form form-horizontal" id="form-member-add">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" v-model="account" class="input-text" value="" placeholder="请输入手机号"
                           name="account">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="password" v-model="password" class="input-text" placeholder="请输入密码" name="password">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="password" class="input-text" v-model="repassword" placeholder="请输入确认密码"
                           name="repassword">
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" @click="member_add" value="提交">
                </div>
            </div>
        </form>
    </article>
</div>

<script>
    new Vue({
        el: '#password',
        data: {
            repassword: '',
            password: '',
            account: '',
        },
        created() {

        },
        methods: {
            //注册会员
            member_add: function () {
                var tel = /^1[3-9](\d{9})$/
                if (this.repassword == this.password && this.password.length >= 6 && tel.test(this.account)) {
                    axios.post('/admin/Service/registered',
                        {
                            repassword: this.repassword,
                            password: this.password,
                            request_type: 'h5',
                            account: this.account,
                        }
                    ).then(response => {
                        if (response.data.status == 200) {
                            this.repassword = '';
                            this.password = '';
                            this.account = '';

                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        } else {
                            layer.alert(response.data.msg)
                        }
                    })
                } else {
                    if (this.repassword != this.password) {
                        layer.alert('2次密码不一致!');
                    }
                    else if (this.password.length < 6) {
                        layer.alert('密码至少6位!');
                    } else {
                        layer.alert('不是正确的手机号!');
                    }

                }

            }
        }
    });
</script>

